<%--
  Created by IntelliJ IDEA.
  User: chenweiyi
  Date: 2018/2/26
  Time: 上午9:32
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>支付页面</title>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="../media/js/jquery-1.12.4.min.js"> </script>
    <style type="text/css">
        body,div{
            margin:0;
        }
        .header{
            text-align: center;
            background: #4CAF50;
        }
        .header h4{
            padding: 10px;
            color: #fff;
            font-weight: normal;
            font-size: 1.2em;
        }
        .bottom{
            position:fixed;
            bottom: 0;
            width:100%;
            padding: 10px 8px;
            background: #4CAF50;
            color: #ffffff;
            font-size:1.2em;
        }
        .pull-right{
            float:right;
        }
        .btn-pay{
            color:#fff;
            margin-right:8px;
            font-size:1em;
        }
    </style>
</head>
<body>
    <div class="header">
        <h4>${title}</h4>
    </div>
    <div style="font-size:1.2em;margin-bottom:2em;">
        <span>订单号:</span>
        <span>${orderNo}</span>
    </div>
    <div style="font-size: 1.2em;">
        <input type="radio" name="payType" checked value="1"/> 微信
        <input type="radio" name="payType" value="2"/> 支付宝
    </div>
    <div class="bottom">
        <span>金额:${price}元</span>
        <button type="button" class="btn-pay pull-right" id="submitBtn">立即支付</button>
    </div>
</body>
<script type="text/javascript">
    $(function(){
        $('#submitBtn').on('click',function(e){
            var payType = $('input[name=payType]:checked').val();
            $.ajax({
               url:'../pay/pay',
               type:'post',
               data:{
                   payType:payType,
                   outTradeNo:'${orderNo}'
               },
               success:function(result){
                    if(payType == "2"){
                        console.log(result);
                       $('body').html(result);
                    }else{

                    }
               },
                error:function(XHR){

                }
            });
            $('#submitBtn').off('click');
        });
    });
</script>
</html>
